<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title> 用户登录界面 ${webInfo.name}</title>
    <link rel="shortcut icon" href=${pageContext.request.contextPath}/static/favicon.ico type=image/x-icon>
    <!--字体图标样式-->
    <link href="${pageContext.request.contextPath}/static/default/javaex/pc/css/icomoon.css" rel="stylesheet"/>
    <!--动画样式-->
    <link href="${pageContext.request.contextPath}/static/default/javaex/pc/css/animate.css" rel="stylesheet"/>
    <!--骨架样式-->
    <link href="${pageContext.request.contextPath}/static/default/javaex/pc/css/common.css" rel="stylesheet"/>
    <!--皮肤（缇娜）-->
    <link href="${pageContext.request.contextPath}/static/default/javaex/pc/css/skin/tina.css" rel="stylesheet"/>
    <script src="${pageContext.request.contextPath}/static/default/javaex/pc/lib/jquery-1.7.2.min.js"></script>
    <!--核心组件-->
    <script src="${pageContext.request.contextPath}/static/default/javaex/pc/js/javaex.min.js"></script>
    <link href="${pageContext.request.contextPath}/static/default/css/loginreg.css" rel="stylesheet"/>
    <script src="${pageContext.request.contextPath}/static/default/js/cookie.js"></script>

	<link rel="stylesheet" href="${pageContext.request.contextPath}/webjars/bootstrap/3.3.5/css/bootstrap.min.css" />
	<script src="${pageContext.request.contextPath}/webjars/jquery/3.1.1/jquery.min.js"></script>
	<script src="${pageContext.request.contextPath}/webjars/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div>
    <div class="register-title-con">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header" style="margin-left: 100px">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                            data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">Brand</a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li><a href="${webInfo.domain}"><font style="vertical-align: inherit;">首页</font></a></li>
                        <li class="active"><a href="${pageContext.request.contextPath}/page/portal/user/login_page.jsp">登陆</a></li>
                        <li><a href="${pageContext.request.contextPath}/page/portal/user/register_page.jsp"
                               class="fr account-login"><font
                                style="vertical-align: inherit;">注册</font></a></li>
                        <li><a href="#">商品</a></li>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                               aria-expanded="false">Dropdown <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="#">这里没东西</a></li>
                                <li><a href="#">你不要按我</a></li>
                                <li><a href="#">真的没东西</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="#">中国人不骗中国人</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="#">为中华民族崛起而奋斗</a></li>
                            </ul>
                        </li>
                    </ul>
                    <form class="navbar-form navbar-right">
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="Search">
                        </div>
                        <button type="submit" class="btn btn-default">Submit</button>
                    </form>
                    <%--					<ul class="nav navbar-nav navbar-right">--%>
                    <%--						<li><a href="#">Link</a></li>--%>
                    <%--						<li class="dropdown">--%>
                    <%--							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>--%>
                    <%--							<ul class="dropdown-menu">--%>
                    <%--								<li><a href="#">Action</a></li>--%>
                    <%--								<li><a href="#">Another action</a></li>--%>
                    <%--								<li><a href="#">Something else here</a></li>--%>
                    <%--								<li role="separator" class="divider"></li>--%>
                    <%--								<li><a href="#">Separated link</a></li>--%>
                    <%--							</ul>--%>
                    <%--						</li>--%>
                    <%--					</ul>--%>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav>
        <%--        <div class="register-title-subcon">--%>
        <%--            <a href="${pageContext.request.contextPath}/portal/register.action" class="fr account-login"><font
                           style="vertical-align: inherit;">用户注册</font></a>
        <%--            <div class="qiyiLogo"><a href="${webInfo.domain}"><font style="vertical-align: inherit;">首页</font></a></div>--%>
        <%--        </div>--%>
    </div>

    <div class="login-step-con">
        <div class="login-frame login-frame-st1 login-frame-stm login-frame-tw">
            <div class="login-frame-top">
                <form id="form">
                    <div class="login-frame-ti">
                        <h2 class="login-title" style=font-size:30px><b>欢迎登陆</b></h2>
                        <div class="info-container">
                            <p class="errorInfo vh"><span>账号错误</span></p>
                            <div class="tip-container tip-account-container">
                                <p class="tip-info">请输入账号</p>
                                <input type="text" class="txt-info txt-account" name="loginName"/>
                            </div>
                        </div>
                        <div class="info-container">
                            <p class="errorInfo vh">
                                <span>密码错误</span>
                            </p>
                            <div class="tip-container tip-pwd-container">
                                <p class="tip-info">请输入密码</p>
                                <input type="password" class="txt-info txt-password" name="passWord"/>
                            </div>
                            <a href="javascript:;" class="eye-close"></a>
                        </div>
                        <div class="forget-pwd fr">
                            <a href="${pageContext.request.contextPath}/portal/find_pwd.action">忘记密码</a>
                        </div>
                        <a href="javascript:;" onclick="login()" class="btn-green btn-login">登录</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    $('input[type="text"], input[type="password"]').focus(function () {
        $(this).parent().parent().addClass("accountIn");
    });
    $('input[type="text"], input[type="password"]').blur(function () {
        if ($(this).val() == "") {
            $(this).parent().parent().removeClass("accountIn");
        }
    });

    function login() {
        $.ajax({
            url: "${pageContext.request.contextPath}/portal/user_info/login.json",
            type: "POST",
            dataType: "json",
            data: $("#form").serialize(),
            success: function (rtn) {
                if (rtn.code == "000000") {
                    var info = rtn.data.info;

                    delCookie("UID");
                    delCookie("userToken");
                    setCookie("UID", info.UID);
                    setCookie("userToken", info.userToken);

                    // 跳转到首页
                    window.location.href = "${pageContext.request.contextPath}/";
                } else {
                    javaex.optTip({
                        content: rtn.message,
                        type: "error"
                    });
                }
            }
        });
    }
</script>
</html>
